<?php

namespace App\Http\Controllers\Admin;

use Illuminate\Http\Request;
use Validator;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\ThrottlesLogins;
use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;
use App\Admin;
class AuthController extends Controller
{
    use AuthenticatesAndRegistersUsers, ThrottlesLogins;

    protected $redirectTo = '/admin';
    protected $guard = 'admin';
    protected $loginView = 'admin.login';
    protected $registerView = 'admin.register';

    public function __construct()
    {
        $this -> middleware('guest:admin',['except'=>'logout']);
    }

    public function validator(array $data)
    {
    	return Validator::make($data,[
    		'name' => 'required|max:255',
    		'email' => 'required|email|max:255|unique:admins',
    		'password' => 'required|confirmed|min:6',
    		]);
    }

    protected function create(array $data)
    {
    	return Admin::create([
    		'name' => $data['name'],
    		'email' => $data['email'],
    		'password' => bcrypt($data['password']),
    		]);
    }
}
